/*player.js
*/
//dx dy is der direction vector
function player(pong){
	this.x = 0;
	this.y = 0;
	this.width = 20;
	this.height = 100;
	this.dx = 0;
	this.dy = 0;
	this.speed = 10;
	this.points = 9;
	var buffer = new Array();
	
	this.serverTick = function(){
		var newX = this.x+this.dx*this.speed;
		var newY = this.y+this.dy*this.speed;
		if(newY-(this.height/2) <= 10)return;
		if(newY+(this.height/2) >= pong.height-10)return;
		this.x = newX;
		this.y = newY;
	};
	this.clientTick = function(){
		this.serverTick();
	};
	this.update = function(msg){};
	this.addPoint = function(){
		this.points++;
	};
	this.setDirection = function(dx, dy){
		if(this.dx != dx || this.dy != dy ){
			this.dx = dx;
			this.dy = dy;
			var data = new Array(this.x, this.y, this.dx, this.dy, pong.loopCount);
			pong.socket.send('player', pong.enemy, data);			
		}

	};
}